package com.yuwei.competition3.common;

import lombok.Data;

import java.io.Serializable;

/**
 * 用户服务
 *
 * @author yuwei
 * @date 20:23 2024/4/23
 */
@Data
public class BaseResponse<T>  implements Serializable {
    private int code;
    private String message;
    private T data;
    public BaseResponse(int code,T data,String message){
        this.code = code;
        this.data = data;
        this.message = message;
    }
    public static <T> BaseResponse<T> success(T data,String message){
        return new BaseResponse(1,data,message);
    }
    public static <T> BaseResponse<T> error(ErrorCode error){
        return new BaseResponse(error.getCode(),null,error.getMessage());
    }
    public static <T> BaseResponse<T> error(int code, String message){
        return new BaseResponse(code,null,message);
    }
}
